#ifndef ALARMEVENTTABLEMODEL_H
#define ALARMEVENTTABLEMODEL_H

#include <QAbstractTableModel>
#include "AlarmEvent.h"

class AlarmManager;
class AlarmEventTableModel : public QAbstractTableModel {
    Q_OBJECT
public:
    explicit AlarmEventTableModel(AlarmManager *alarmManager1,QObject *parent = nullptr);

    // 核心接口实现
    int rowCount(const QModelIndex &parent = QModelIndex()) const override;
    int columnCount(const QModelIndex &parent = QModelIndex()) const override;
    QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
    QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;

        inline bool insertRow(int row, const QModelIndex &parent = QModelIndex());
    // 数据操作接口
        // 修正后的方法声明
            bool insertRows(int row, int count,
                           const QModelIndex &parent = QModelIndex()) override;
            bool removeRows(int row, int count,
                           const QModelIndex &parent = QModelIndex()) override;
    bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;

    // 辅助方法
    AlarmEvent getEventAt(int row) const;
    QList<AlarmEvent> getAllEvents() const;

    Qt::ItemFlags flags(const QModelIndex &index) const override;

private:
//    QList<AlarmEvent> events;
    AlarmManager *alarmManager;
};

#endif // ALARMEVENTTABLEMODEL_H
